package com.zyz.demo.mapper;

import com.zyz.demo.model.BlogInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogMapper {

    @Select("select id,title,content,`user_id`,update_time from blog where delete_flag = 0 and id = #{blogId}")
    BlogInfo selectBlogInfoByBlogId(Integer blogId);

    Integer updateBlogByBlogId(BlogInfo blogInfo);

    @Select("select id,title,content,`user_id`,update_time from blog where delete_flag = 0 order by id desc")
    List<BlogInfo> getBlogAll();

    @Insert("insert into blog (title,content,`user_id`) values (#{title},#{content},#{userId})")
    Integer addBlog(BlogInfo blogInfo);
}
